package io.renren.modules.sys.controller;

import io.renren.common.utils.R;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.service.GetPasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author hsp
 * @Description TODO
 * @createTime 2020年09月21日 14:01:00
 */
@RestController
@RequestMapping("sys/password")
public class SysPasswordController {

    @Autowired
    private GetPasswordService getPasswordService;

    @GetMapping("/verify")
    public R passwordVerify(@RequestParam Map<String, Object> params
    ) {
        String state = getPasswordService.verifyEmailAndUsername(params);
        return R.ok().put("state",state);
    }

    @GetMapping("/send")
    public R sendEmail(@RequestParam Map<String, Object> params) {
        String state = getPasswordService.sendEmail(params);
        return R.ok().put("state",state);

    }

    @GetMapping("/codeVerify")
    public R codeVerify(@RequestParam Map<String, Object> params
    ) {
        String state = getPasswordService.codeVerify(params);
        return R.ok().put("state",state);

    }

    @PostMapping("/updatePwd")
    public R updatePwd(@RequestBody SysUserEntity sysUserEntity) {
        String message = getPasswordService.updatePwd(sysUserEntity);
        return R.ok().put("message",message);
    }
}
